package com.mvp.shq.washer;

import android.app.Application;
import android.content.Context;
import android.content.res.Resources;

import com.mvp.shq.washer.utils.SpUtil;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreater;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreater;
import com.scwang.smartrefresh.layout.api.RefreshFooter;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.umeng.analytics.MobclickAgent;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

import cn.jpush.android.api.JPushInterface;


/**
 * Created by Administrator on 2017/6/14.
 */

public class APP extends Application {
    private static APP app;
    static {
        //设置全局的Header构建器
        SmartRefreshLayout.setDefaultRefreshHeaderCreater(new DefaultRefreshHeaderCreater() {
            @Override
            public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
                layout.setPrimaryColorsId(R.color.white, R.color.text_black);//全局设置主题颜色
                return new ClassicsHeader(context).setSpinnerStyle(SpinnerStyle.Translate);//指定为经典Header，默认是 贝塞尔雷达Header
            }
        });
        //设置全局的Footer构建器
        SmartRefreshLayout.setDefaultRefreshFooterCreater(new DefaultRefreshFooterCreater() {
            @Override
            public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
                //指定为经典Footer，默认是 BallPulseFooter
                return new ClassicsFooter(context).setSpinnerStyle(SpinnerStyle.Translate);
            }
        });
    }
    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        //友盟统计
        MobclickAgent.openActivityDurationTrack(false);
        MobclickAgent.enableEncrypt(true);//6.0.0版本及以后
        //友盟分享
        UMShareAPI.get(this);
        initUMShare();
        //jpush
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
        //logger
        Logger.addLogAdapter(new AndroidLogAdapter());
        //SpUtil
        SpUtil.init(this);
    }
    private void initUMShare(){
        PlatformConfig.setWeixin("wx18074b4c6adce3f8","518c941237c813c7a047c06ea9f3405e");
        PlatformConfig.setQQZone("1106304587","twZlVxcx0KMksFNw");
    }
    public static Context getAppContext() {
        return app;
    }

    public static Resources getAppResources() {
        return app.getResources();
    }

    public static APP getApp(){return app;}

}
